<div class="content-wrapper">

    <section class="content-header">
        <?php echo $this->partial('layout/breadcrumb'); ?>

        <h1 class="pull-right">
            <?php echo $this->HelpUrl('financePayableList'); ?>
        </h1>

    </section>

    <section class="content">
        <?php echo $this->partial('layout/messages'); ?>

        <div class="row">
            <div class="col-xs-12">
                <div class="box erp-box">

                    <div class="box-body table-responsive no-padding">
                        <table class="table table-hover">
                            <thead>
                            <tr class="erp-bg-thead">
                                <th width="10%"><?php echo $this->translate('采购单号'); ?></th>
                                <!--<th width="10%"><?php echo $this->translate('入库单号'); ?></th>-->
                                <th width="10%"><?php echo $this->translate('供应商'); ?></th>
                                <th width="10%"><?php echo $this->translate('付款方式'); ?></th>
                                <th width="10%"><?php echo $this->translate('采购金额'); ?></th>
                                <th width="10%"><?php echo $this->translate('已付金额'); ?></th>
                                <th width="10%"><?php echo $this->translate('操作'); ?></th>
                            </tr>
                            <?php
                            $sForm = $this->searchForm;
                            $sForm->prepare();
                            ?>
                            <?php echo $this->form()->openTag($sForm); ?>
                            <tr>
                                <td>
                                    <?php echo $this->formElement($sForm->get('p_order_sn')); ?>
                                    <?php echo $this->formElementErrors($sForm->get('p_order_sn'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <?php echo $this->formElement($sForm->get('supplier_name')); ?>
                                    <?php echo $this->formElementErrors($sForm->get('supplier_name'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <?php echo $this->formElement($sForm->get('payment_code')); ?>
                                    <?php echo $this->formElementErrors($sForm->get('payment_code'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <p>
                                        <?php echo $this->formElement($sForm->get('pur_start_amount')); ?>
                                    </p>
                                    <div>
                                        <?php echo $this->formElement($sForm->get('pur_end_amount')); ?>
                                    </div>
                                    <?php echo $this->formElementErrors($sForm->get('pur_start_amount'), ['class'=>'error-message']);?>
                                    <?php echo $this->formElementErrors($sForm->get('pur_end_amount'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <p>
                                        <?php echo $this->formElement($sForm->get('start_amount')); ?>
                                    </p>
                                    <div>
                                        <?php echo $this->formElement($sForm->get('end_amount')); ?>
                                    </div>
                                    <?php echo $this->formElementErrors($sForm->get('start_amount'), ['class'=>'error-message']);?>
                                    <?php echo $this->formElementErrors($sForm->get('end_amount'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <button type="submit" class="btn btn-info btn-sm"><i class="fa fa-search"></i></button>
                                    <?php if(!empty(array_filter($sForm->getData()))) { ?>
                                        <a href="<?php echo $this->url('finance-payable');?>" class="btn btn-default btn-sm"><i class="fa fa-reply"></i></a>
                                    <?php } ?>
                                </td>
                            </tr>
                            <?php echo $this->form()->closeTag(); ?>
                            </thead>

                            <?php if($this->PayableList) foreach ($this->PayableList as $PayableValue) {?>
                                <tr>
                                    <td><?php echo $this->escapeHtml($PayableValue->getPOrderSn()); ?></td>
                                    <!--<td></td>-->
                                    <td><?php echo $this->escapeHtml($PayableValue->getSupplierName());?></td>
                                    <td><?php echo $this->PurchaseHelper()->orderPayment($PayableValue->getPaymentCode());?></td>
                                    <td><?php echo $this->erpCurrencyFormat($PayableValue->getPaymentAmount()); ?></td>
                                    <td>
                                        <span <?php echo ($PayableValue->getPaymentAmount() == $PayableValue->getFinishAmount() ? 'class="text-green"' : ''); ?>><?php echo $this->erpCurrencyFormat($PayableValue->getFinishAmount()); ?></span>
                                        <?php if($PayableValue->getFinishAmount() != 0.0000) { ?>
                                        <a href="<?php echo $this->url('finance-payable',
                                            ['action'=>'payableLog', 'id'=>$PayableValue->getPayableId()]); ?>" title="<?php echo $this->translate('付款记录'); ?>"><i class="fa fa-book text-green"></i></a>
                                        <?php } ?>
                                    </td>
                                    <td>
                                        <?php if($PayableValue->getPaymentAmount() != $PayableValue->getFinishAmount()) { ?>
                                        <a href="<?php echo $this->url('finance-payable',
                                            ['action'=>'addPayable', 'id'=>$PayableValue->getPayableId()]); ?>"
                                           class="btn btn-xs btn-success"><i class="fa fa-usd"></i> <?php echo $this->translate('付款'); ?></a>
                                        <?php } ?>
                                        <a href="<?php echo $this->url('finance-payable',
                                            ['action'=>'show', 'id'=>$PayableValue->getPayableId()]); ?>"
                                           class="btn btn-xs btn-info"><i class="fa fa-info-circle"></i> <?php echo $this->translate('查看'); ?>
                                        </a>
                                    </td>
                                </tr>
                            <?php } ?>
                        </table>
                    </div>
                    <div class="box-footer clearfix">
                        <?php echo $this->paginationControl($this->PayableList, 'Sliding', 'layout/page', ['route' => 'finance-payable']); ?>
                    </div>
                </div>

            </div>
        </div>

    </section>
</div>